import { _decorator, Component, Node } from "cc";
import { EventType } from "../model";
import { EventManager } from "../runtime/event-manager";
const { ccclass, property } = _decorator;

@ccclass("RenderManager")
export abstract class RenderManager extends Component {
  abstract render(): void;

  private realRender: Function;

  protected onLoad(): void {
    this.realRender = this.render.bind(this);
    EventManager.Instance.on(EventType.Render, this.realRender);
  }

  protected onDestroy(): void {
    EventManager.Instance.off(EventType.Render, this.realRender);
  }

  start() {
    this.realRender();
  }
}
